#include<sys/types.h>
#include<sys/stat.h>
#include<fcntl.h>
#include<sys/mman.h>
#include<unistd.h>


int *p = NULL;
int main(void){
    int x,y;
    int lcd_fd = open("/dev/fb0",O_RDWR);
    if (-1 == lcd_fd)
    {
        perror("open() lcd failed\n");
        return -1;
    }
    else
    {
        printf("open() lcd success\n");
    }

    p = mmap(NULL,800*480*4, PROT_READ|PROT_WRITE, MAP_SHARED,lcd_fd,0);

    if (NULL == p)
    {
        perror("mmap() failed\n");
        return 0;
    }

    int color = 0x000000;
    for (y = 0; y < 160; y++)
    {
        for ( x = 0; x < 800; x++)
        {
            *(p+x+y*800) = color;
        }
        
    }
    color = 0xFF0000;
    for (y = 160; y < 320; y++)
    {
        for ( x = 0; x < 800; x++)
        {
            *(p+x+y*800) = color;
        }
        
    }
    color = 0xFFFF00;
    for (y = 320; y < 480; y++)
    {
        for ( x = 0; x < 800; x++)
        {
            *(p+x+y*800) = color;
        }
        
    }
    
    close(lcd_fd);
}
